---
image: {{ $.ModuleName }}/{{ $.ImageName }}
fromImage: common/distroless
import:
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact
  add: /ovirt-csi-driver
  to: /ovirt-csi-driver
  before: setup
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-binaries-artifact
  add: /relocate
  to: /
  before: install
  includePaths:
  - '**/*'
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-binaries-artifact
  add: /lib64
  to: /lib64
  before: install
  includePaths:
  - 'libresolv*'
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-binaries-artifact
  add: /lib/udev/scsi_id
  to: /lib/udev/scsi_id
  before: setup
docker:
  ENTRYPOINT: ["/ovirt-csi-driver"]
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact
from: {{ $.Images.BASE_GOLANG_19_BULLSEYE_DEV }}
git:
- add: /{{ $.ModulePath }}modules/030-{{ $.ModuleName }}/images/{{ $.ImageName }}/patches
  to: /patches
  includePaths:
  - '**/*.patch'
  stageDependencies:
    install:
    - '**/*.patch'
mount:
- fromPath: ~/go-pkg-cache
  to: /go/pkg
shell:
  install:
  - export GO_VERSION=${GOLANG_VERSION}
  - export GOPROXY={{ $.GOPROXY }}
  - export VERSION="release-4.17"
  - mkdir -p /src
  - git clone --depth 1 --branch ${VERSION} {{ $.SOURCE_REPO }}/openshift/ovirt-csi-driver.git /src
  - cd /src
  - rm -rf vendor
  - find /patches -name '*.patch' | xargs git apply --verbose
  - go mod tidy
  - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w -X version.Version=${VERSION}" -o /ovirt-csi-driver ./cmd/ovirt-csi-driver/ovirt-csi-driver.go
---
{{- $csiBinaries := "/bin/chmod /bin/mount /bin/mkdir /bin/rmdir /bin/umount /bin/findmnt /bin/lsblk /sbin/badblocks /sbin/blockdev /sbin/blk* /sbin/btrfs* /sbin/dumpe2fs /sbin/e2* /sbin/findfs /sbin/fsck* /sbin/fsfreeze /sbin/fstrim /sbin/mke2fs /sbin/mkfs* /sbin/resize2fs /sbin/xfs_repair /usr/sbin/nvme /usr/sbin/parted /usr/sbin/xfs*" }}
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-binaries-artifact
from: {{ $.Images.BASE_ALT_DEV }}
shell:
  setup:
    - /binary_replace.sh -i "{{ $csiBinaries }}" -o /relocate
